package com.htl.exampro.paper.controller;

import com.htl.exampro.base.model.ServerResponse;
import com.htl.exampro.paper.pojo.vo.PaperQuestionVO;
import com.htl.exampro.paper.service.PaperQuestionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 试卷试题关联表 前端控制器
 * </p>
 *
 * @author hehehe
 * @since 2025-05-26
 */
@Tag(name = "试卷问题管理", description = "试卷问题相关接口")
@RestController
@RequestMapping("/paper-question")
public class PaperQuestionController {
    @Autowired
    private PaperQuestionService paperQuestionService;

    @Operation(summary = "查询试卷问题", description = "根据主键查询试卷信息")
    @GetMapping("/{id}")
    public ServerResponse<List<PaperQuestionVO>> queryQuestionByPaperId(@PathVariable("id") String id) {
        List<PaperQuestionVO> paperQuestionVOS = paperQuestionService.queryQuestionIdsByPaperId(id);
        return ServerResponse.success(paperQuestionVOS);
    }

    @Operation(summary = "查询试卷问题", description = "根据试卷ID和问题ID查询试卷问题关联信息")
    @GetMapping("/{paperId}/{questionId}")
    public ServerResponse<PaperQuestionVO> queryPaperQuestion(@PathVariable("paperId") String paperId,@PathVariable("questionId") String questionId) {
        PaperQuestionVO paperQuestionVO = paperQuestionService.queryPaperQuestion(paperId,questionId);
        return ServerResponse.success(paperQuestionVO);
    }

}
